
#include "kb.h"                 // keybaord event type 
#include "touch_algorithm.h"    // touch event type 
#include "custom_event.h"
#include "gui.h"                // GUI header

#include "views.h"              // include all views 
#include "log.h"                // LOG file 

#define VTLOG0      LOG_INFO0
#define VTLOG1      LOG_INFO1
#define VTLOG2      LOG_INFO2
#define VTLOG3      LOG_INFO3
#include "xapp_clock.h"
#include "xapp_access.h"
#include "xapp_profile.h"
#include "xapp_localize.h"
#include "views_util.h"

enum tagTimer
{
    tagTimerStart = 0,
    tagTimerYearSelected,
    tagTimerMonthSelected,
    tagTimerDaySelected,
    tagTimerYearClickSelected,
    tagTimerMonthClickSelected, 
    tagTimerDayClickSelected,
};

enum fsmTimer
{
    fsmTimerIdle = 0,    
    fsmTimerUpdate, 
};

// declare function 
GUI_VIEW_FUNC_DECLARE_ALL;
static void local_view_event_handler( uint32_t tag );


static setup_date_st date_st={
    .textid=TEXT_TAG_SET_DATE,
    .pyear=NULL,
    .pmonth=NULL,
    .pday=NULL,
    .cb=NULL
    },*pdate_st=&date_st;

void view_enter_setup_date(const gui_view_t *parent,uint16_t textid,uint8_t *p_year,uint8_t *p_month,uint8_t *p_day,setup_date_cb_t cb)
{
    pdate_st->textid = textid;
	pdate_st->pyear = p_year;
	pdate_st->pmonth = p_month;
    pdate_st->pday = p_day;
    if(p_year) pdate_st->year  = *p_year;
    if(p_month)pdate_st->month = *p_month;
    if(p_day)  pdate_st->day   = *p_day;
    pdate_st->parent = parent;
    pdate_st->cb = cb;
    gui_view_create_sub( parent, &viewSetDate );
}

static const uint16_t YEAR_text = 0x0059;// 'Y'的unicode
static const uint16_t MONTH_text = 0x004D;// 'M'的unicode
static const uint16_t DAY_text = 0x0044;// 'D'的unicode
static uint8_t textbuf0[20];

#define ITEM_HEIGHT (GUI_LCD_RES_V/5)
#define PICK_HEIGHT (ITEM_HEIGHT*3)
#define Y_OFFSET    (ITEM_HEIGHT*2/3)

#define YEAR_WIDTH  (GUI_LCD_RES_H*80/240)
#define MONT_WIDTH  (GUI_LCD_RES_H*80/240)
#define DAY_WIDTH   (GUI_LCD_RES_H*80/240)

const static ui_widgets_type_t wglTimerSelect[] = 
{
    // background 
    [0] = uiCanvas(0, 0, GUI_LCD_RES_H, GUI_LCD_RES_V, COLOR_BLACK ),

    // line 
    [1] = uiCanvas( SIZE_SCALE(10), Y_OFFSET+ITEM_HEIGHT*1-3 , GUI_LCD_RES_H - SIZE_SCALE(10) * 2, 2, COLOR_GRAY ),
    // line2 
    [2] = uiCanvas( SIZE_SCALE(10), Y_OFFSET+ITEM_HEIGHT*2-3 , GUI_LCD_RES_H - SIZE_SCALE(10) * 2, 2, COLOR_GRAY ), 

    // time set(picker) hour, center Y = (y * 2 + h ) / 2 - height / 2 h = 3 * 20 + 2 *pitch 
    [3] = uiPicker( SIZE_SCALE(0),          Y_OFFSET,YEAR_WIDTH,PICK_HEIGHT, COLOR_WHITE, ALIGN_MIDDLE_CENTOR, ENCODING_ASCII, FONT_ASCII_1_28_37, (ITEM_HEIGHT-37)/1 ),
    [4] = uiPicker( YEAR_WIDTH,             Y_OFFSET,MONT_WIDTH,PICK_HEIGHT, COLOR_WHITE, ALIGN_MIDDLE_CENTOR, ENCODING_ASCII, FONT_ASCII_1_28_37, (ITEM_HEIGHT-37)/1 ),
    [5] = uiPicker( YEAR_WIDTH+MONT_WIDTH,  Y_OFFSET,DAY_WIDTH ,PICK_HEIGHT, COLOR_WHITE, ALIGN_MIDDLE_CENTOR, ENCODING_ASCII, FONT_ASCII_1_28_37, (ITEM_HEIGHT-37)/1 ),    
    // unit ( 40 * 2 + 60 ) / 2 - 20 / 2 = 60
    [6] = uiLabel( YEAR_WIDTH-20,                     Y_OFFSET+ITEM_HEIGHT*1, 24, 24, COLOR_BLACK, COLOR_ORANGE, ALIGN_LEFT_TOP, FILL_NONE, ENCODING_UNICODE, FONT_UNICODE_20_29, &YEAR_text, 1 ), 
    // time set(picker) minute 
    [7] = uiLabel( YEAR_WIDTH+MONT_WIDTH-20,          Y_OFFSET+ITEM_HEIGHT*1, 24, 24, COLOR_BLACK, COLOR_ORANGE, ALIGN_LEFT_TOP, FILL_NONE, ENCODING_UNICODE, FONT_UNICODE_20_29, &MONTH_text, 1 ),
    // day
    [8] = uiLabel( YEAR_WIDTH+MONT_WIDTH+DAY_WIDTH-20,Y_OFFSET+ITEM_HEIGHT*1, 24, 24, COLOR_BLACK, COLOR_ORANGE, ALIGN_LEFT_TOP, FILL_NONE, ENCODING_UNICODE, FONT_UNICODE_20_29, &DAY_text, 1 ),
    
    // mask color 
    [7+2] = uiColorReplacer( 0, Y_OFFSET+ITEM_HEIGHT*1, GUI_LCD_RES_H, ITEM_HEIGHT, COLOR_WHITE, COLOR_ORANGE ),
    // mask color 
    //[8] = uiColorReplacer( 0, (GUI_LCD_RES_V-Y_OFFSET-10-PICK_HEIGHT)/2+ITEM_HEIGHT*1-3, GUI_LCD_RES_H, ITEM_HEIGHT, COLOR_WHITE, COLOR_ORANGE ), 
    
    //设置日期
	[8+2] = uiTextbox( 0, 0, GUI_LCD_RES_H/2, 0, COLOR_BLACK, COLOR_WHITE, ALIGN_MIDDLE_CENTOR,   FILL_NONE, ENCODING_UNICODE, FONT_UNICODE_20_29 ),

    //时间
	[9+2] = uiNumberlistWithBuffer( GUI_LCD_RES_H/3*2, 0, GUI_LCD_RES_H/3-0, 0, COLOR_BLACK, COLOR_WHITE, ALIGN_RIGHT_CENTOR, FILL_NONE, ENCODING_ASCII, FONT_ASCII_1_22_29, "%02d:%02d", textbuf0, 5 ),

    // button bg
	[10+2] = uiPictureBox( IMG_Exercise_Play_Stop_Button_075_075_02/*IMG_Project_Small_Yellow_ItemBG_228_036_01*/, 1, (GUI_LCD_RES_H-75)/2, GUI_LCD_RES_V-75, 75, 75 ),
    
    // button text -36+5 加5是因为文本被认定为高度29,但实际可见部分高度仅为20,因此文字会被往上顶,导致竖直方向不居中
	[11+2] = uiTextbox( 0, GUI_LCD_RES_V-12*2-36+5, GUI_LCD_RES_H, 12*2+36, COLOR_BLACK, COLOR_WHITE, ALIGN_MIDDLE_CENTOR,   FILL_NONE, ENCODING_UNICODE, FONT_UNICODE_20_29 ), 
    
    [12+2] = uiColorReplacer( 0, Y_OFFSET+ITEM_HEIGHT*1, GUI_LCD_RES_H, ITEM_HEIGHT, COLOR_BLACK, REAL_COLOR_GRAY ),
};

#if ITEM_HEIGHT < 37
#error "item height is too small"
#endif
const static ui_widgets_type_t wglTimerSelectTouch_Click[] = 
{
    [0] = uiTouch( 0, GUI_LCD_RES_V-12*2-36, GUI_LCD_RES_H, 12*2+36, tagTimerStart ), 
    [1] = uiTouch( 0, 	                  0, YEAR_WIDTH, ITEM_HEIGHT*4,  tagTimerYearClickSelected ),
    [2] = uiTouch( YEAR_WIDTH,            0, MONT_WIDTH, ITEM_HEIGHT*4,  tagTimerMonthClickSelected ), 
    [3] = uiTouch( YEAR_WIDTH+MONT_WIDTH, 0, DAY_WIDTH , ITEM_HEIGHT*4,  tagTimerDayClickSelected ), 
};

const static ui_widgets_type_t wglTimerSelectTouch_Down[] = 
{
    [0] = uiTouch( 0, 	                  0, YEAR_WIDTH, ITEM_HEIGHT*4,  tagTimerYearSelected ),
    [1] = uiTouch( YEAR_WIDTH,            0, MONT_WIDTH, ITEM_HEIGHT*4,  tagTimerMonthSelected ), 
    [2] = uiTouch( YEAR_WIDTH+MONT_WIDTH, 0, DAY_WIDTH , ITEM_HEIGHT*4,  tagTimerDaySelected ), 
};

GUI_VIEW_DEF( viewSetDate ) = 
{
    // name 
    .name = "Settings+date",
    
    // init 
    .init = initialize,
    .display_func = display_callback_func,
    .refresh_func_check = display_refresh_func,
    .destroy_func = on_destroy_func,
    .set_parent_func = on_set_parent_func, 
    
    // input 
    .on_touch = on_touch,
    .on_button = on_button,
    .on_event_update = on_event_update,     
    
    .pWidgetlist =  (ui_widgets_type_t*)wglTimerSelect /* 3. fill with widgets list name */,
    .widget_cnt = WIDGET_COUNT( wglTimerSelect ), /* 3. fill with widgets list name */

    .flag = GUI_VIEW_FLAG_FUNC
};


#define INC_STEP        (10)
#define INC_OFFSET      (20)
#define DEC_OFFSET      (-20)

#define FLING_DISABLE           0
#define FLING_YEAR_ENABLED      1
#define FLING_MONTH_ENABLED     2 
#define FLING_DAY_ENABLED    	3

//static int16_t m_data_offset = 0;

//static int16_t m_hour_delta_y;
//static int16_t m_minute_delta_y; 

static uint8_t m_timer_fling_flags = 0;

static gui_fling_t *m_year_fling; 
static gui_fling_t *m_month_fling;
static gui_fling_t *m_day_fling;
static uint8_t year_selected_index = 0;
static uint8_t month_selected_index = 0;
static uint8_t day_selected_index = 0;
//static int16_t roll_last_total;

static void initialize(gui_menu_t * menu, void* pvParameter)
{
//    uint8_t hour = xapp_clock_get_now()->hour;
//    uint8_t minute = xapp_clock_get_now()->minute;
	
    menu->interval = 0;
    const profile_system_t* p_profile_system = xapp_profile_get_system();
    menu->lifetime = p_profile_system->time_of_light_on * 1000;

//    m_hour_delta_y = -(ITEM_HEIGHT)*hour;
//    m_minute_delta_y = -(ITEM_HEIGHT)*minute; // item height * 1, 设置一个有个值
    year_selected_index = pdate_st->year;
    month_selected_index = pdate_st->month-1;   // 1月对应序号0
    day_selected_index = pdate_st->day-1;       // 1号对应序号0
    
    m_timer_fling_flags = 0;

    // 初始化
    m_year_fling   = gui_fling_get();
    m_month_fling = gui_fling_get();
    m_day_fling = gui_fling_get();
    
    gui_fling_init_t init_obj = GUI_FLING_CONFIG( 0  , Y_OFFSET, YEAR_WIDTH, PICK_HEIGHT, true,  0, 0, ITEM_HEIGHT, 50, m_month_fling );
    gui_fling_init( m_year_fling, &init_obj );
    
    gui_fling_init_t init_obj1 = GUI_FLING_CONFIG( YEAR_WIDTH, Y_OFFSET, MONT_WIDTH, PICK_HEIGHT, false, 0, 0, ITEM_HEIGHT, 50, m_day_fling );
    gui_fling_init( m_month_fling, &init_obj1 );
    
    gui_fling_init_t init_obj2 = GUI_FLING_CONFIG( YEAR_WIDTH+MONT_WIDTH, Y_OFFSET, DAY_WIDTH, PICK_HEIGHT, false, 0, 0, ITEM_HEIGHT, 50, NULL );
    gui_fling_init( m_day_fling, &init_obj2 );
    
    m_year_fling->roll_offset_total = -year_selected_index * ITEM_HEIGHT;
    m_month_fling->roll_offset_total = -month_selected_index * ITEM_HEIGHT;
    m_day_fling->roll_offset_total = -day_selected_index * ITEM_HEIGHT;
}
static void on_set_parent_func(gui_menu_t * menu, const gui_view_t * parent)
{
    p_this_parent = parent;
}
/* 销毁函数
// 在销毁前处理当前信息，比如不允许销毁时，将当前界面状态保存为background。
// true:  允许销毁
// false: 不允许自动销毁，则GUI只关闭当前显示，输入事件仍由当前view进行处理。
          那么view判断当前状态为background时，作出对应background下的按键、触摸等事件反馈
*/
static uint32_t on_destroy_func(gui_menu_t * menu)
{
//    roll_last_total = m_year_fling.roll_offset_total;

    gui_fling_set_disable( m_year_fling );     
    return GUI_DESTROY_RET_DEFAULT; 
}

static void display_callback_func(gui_menu_t * menu)
{
    ui_property_t prop;
    ui_widgets_type_t * widgets = menu->widgets;
    string_t const *s;

    widgets[1].visible = widgets[2].visible = 0;
    
    if( menu->source == GUI_VIEW_REQ_SRC_UPDATE_FLING || IS_REQ_SRC_CREATE( menu->source))
    {
    // 年的选项
    PROP_ASSIGN_PICKER_OFFS(prop,iqw_gui_assets_get_year_items,60,m_year_fling->roll_offset_total);
    PROP_UPDATE_AT_NO( 3 );
    // 获取设置的index
    year_selected_index = widgets[3].uiPicker.extension->picker.index;

    // 松开的时候，强制将picker的delta_y置为0，这样中间数字居中
    PROP_ASSIGN_PICKER_OFFS(prop,iqw_gui_assets_get_month_items,12,m_month_fling->roll_offset_total);
    PROP_UPDATE_AT_NO( 4 );
    // 获取设置的index
    month_selected_index = widgets[4].uiPicker.extension->picker.index;

    // 松开的时候，强制将picker的delta_y置为0，这样中间数字居中
    PROP_ASSIGN_PICKER_OFFS(prop,iqw_gui_assets_get_day_items,31,m_day_fling->roll_offset_total);
    PROP_UPDATE_AT_NO( 5 );
    // 获取设置的index
    day_selected_index = widgets[5].uiPicker.extension->picker.index;
        
    VTLOG3("setdate:year = %d, month = %d, day=%d", widgets[3].uiPicker.extension->picker.delta,  widgets[4].uiPicker.extension->picker.delta,  widgets[5].uiPicker.extension->picker.delta);
    }
    
    if(IS_REQ_SRC_CREATE( menu->source))
    {
    // YEAR单位
    PROP_UPDATE_NULL_AT_NO(6);

    // MONTH单位
    PROP_UPDATE_NULL_AT_NO(7);

    // DAY单位
    PROP_UPDATE_NULL_AT_NO(8);
    
    widgets[6].visible = widgets[7].visible = widgets[8].visible = 0;
    
    //日期设置
    s = xapp_local_text_item_get( pdate_st->textid );
    PROP_ASSIGN_TEXT( prop, s->text, s->len );
    PROP_UPDATE_AT_NO( 8+2 );

    //时间
	{
    uint8_t h = xapp_clock_get_now()->hour;
    uint8_t m = xapp_clock_get_now()->minute;
    if( h > 12 && profile_sys_get_time_format())
      h -= 12;
    prop.numberlist.value[0] = h;
    prop.numberlist.value[1] = m;
    prop.numberlist.cnt = 2;
    PROP_UPDATE_AT_NO( 9+2 );
	}
    
    //保存
    s = xapp_local_text_item_get( TEXT_TAG_WEEKDAY_SIMP_SUNDAY );
    PROP_ASSIGN_TEXT( prop, s->text, s->len );
    PROP_UPDATE_AT_NO( 11+2 );
    widgets[11+2].visible = 0;
    }
}


static int display_refresh_func(gui_menu_t * menu)
{
    // 永远允许刷新
    return 1;
}

static void on_touch(void* pvParameters, gui_menu_t * menu)
{
    tp_algo_evt_t* touch = (tp_algo_evt_t*)pvParameters;
    gui_core_lifetime_refresh( menu );
    switch( touch->type ) 
    {
        case TP_ALGO_EVT_TYPE_DOWN:
            VTLOG0("touch press");
        // 检测触摸按下的位置，判断哪个哪个picker需要拖动
        if( !GUI_WIDGET_LIST_CHECK_TOUCH( wglTimerSelectTouch_Down, WIDGET_COUNT(wglTimerSelectTouch_Down), 0, 0, touch->x, touch->y, local_view_event_handler) )
        {
            m_timer_fling_flags = FLING_DISABLE;
        }
        break;

        case TP_ALGO_EVT_TYPE_UP:
            VTLOG1("touch release: flag = %d", m_timer_fling_flags);
        // 触摸松开，先滚动补偿（由于先产生UP事件再产生滑动事件，这里的补偿会被后续的滑动事件替换掉）
        // 这里必须要执行，不然松开时无法滚动到适应的位置）
        if( m_timer_fling_flags == FLING_YEAR_ENABLED )
        {
            gui_fling_on_touch_release( m_year_fling );
        }
        else if( m_timer_fling_flags == FLING_MONTH_ENABLED )
        {
            gui_fling_on_touch_release( m_month_fling ); 
        }
        else if( m_timer_fling_flags == FLING_DAY_ENABLED )
        {
            gui_fling_on_touch_release( m_day_fling ); 
        }
        else 
        {

        }
        break;

        case TP_ALGO_EVT_TYPE_CLICK:  
        if( GUI_WIDGET_LIST_CHECK_TOUCH( wglTimerSelectTouch_Click, WIDGET_COUNT(wglTimerSelectTouch_Click), 0, 0, touch->x, touch->y, local_view_event_handler) )
        {

        }
        break;

//        case TP_ALGO_EVT_TYPE_HOLD:
//        if(/* !drag_from_top && */touch->deltaY != 0 ) // 需要添加按下时是否在滚动区域中
//        {
//            if( m_timer_fling_flags == FLING_YEAR_ENABLED)        // 年滚动
//            {
//                gui_fling_set_roll( m_year_fling, touch->deltaY );
//            }
//            else if( m_timer_fling_flags == FLING_MONTH_ENABLED ) // 月滚动
//            {
//                gui_fling_set_roll( m_month_fling, touch->deltaY );
//            }
//            else if( m_timer_fling_flags == FLING_DAY_ENABLED )   // 日滚动
//            {
//                gui_fling_set_roll( m_day_fling, touch->deltaY );
//            }
//            else
//            {
//                // nothings to fling
//            }
//        }
//        break;

        // should wait for fling end
        case TP_ALGO_EVT_TYPE_SLIDE_R:
        {
//            if( p_this_parent != NULL )
//            {
//                gui_view_create_return( p_this_parent );
//                p_this_parent = NULL;
//            }
//            else 
//            {
                gui_view_create_return( &viewAppsList );
//            }
            gui_fling_set_disable( m_year_fling );
        }
        break;

        case TP_ALGO_EVT_TYPE_SLIDE_U:
            VTLOG1("touch slide to UP, flag = %d", m_timer_fling_flags );
        if( m_timer_fling_flags == FLING_YEAR_ENABLED)
        {
            gui_fling_switch_item( m_year_fling, 1, true );
            //gui_fling_set_roll( m_year_fling, -ITEM_HEIGHT );
        }
        else if( m_timer_fling_flags == FLING_MONTH_ENABLED )
        {
            gui_fling_switch_item( m_month_fling, 1, true );
            //gui_fling_set_roll( m_month_fling, -ITEM_HEIGHT );
        }
        else if( m_timer_fling_flags == FLING_DAY_ENABLED )
        {
            gui_fling_switch_item( m_day_fling, 1, true );
            //gui_fling_set_roll( m_day_fling, -ITEM_HEIGHT );
        }
        else 
        {
            // nothings to fling 
        }
        break;

        case TP_ALGO_EVT_TYPE_SLIDE_D:
            VTLOG1("touch slide to DOWN, flag = %d", m_timer_fling_flags );
        if( m_timer_fling_flags == FLING_YEAR_ENABLED) // 小时滚动
        {
            gui_fling_switch_item( m_year_fling, 1, false );
            //gui_fling_set_roll( m_year_fling, ITEM_HEIGHT );
        }
        else if( m_timer_fling_flags == FLING_MONTH_ENABLED ) // 分钟滚动
        {
            gui_fling_switch_item( m_month_fling, 1, false );
            //gui_fling_set_roll( m_month_fling, ITEM_HEIGHT );
        }
        else if( m_timer_fling_flags == FLING_DAY_ENABLED ) // 分钟滚动
        {
            gui_fling_switch_item( m_day_fling, 1, false );
            //gui_fling_set_roll( m_day_fling, ITEM_HEIGHT );
        }
        else 
        {
            // nothings to fling 
        }
        break;

        
        default:
            break; 
    }
}

#ifdef BOARD_IQ120
static void on_button(void* pvParameters, gui_menu_t * menu)
{
    kb_evt_t * kb = (kb_evt_t*)pvParameters;
    
    switch( kb->type ) 
    {
        case KB_EVT_CLICK:
        if( kb->idx == 0 || kb->idx == 1 )
        {
            if( p_this_parent != NULL )
            {
                gui_view_create_return( p_this_parent );
                p_this_parent = NULL;
            }
            else 
            {
                gui_view_create( &viewAppsList );
            }
        }
        else if( kb->idx == 2 )
        {
            gui_view_create( &viewWatchface );
        }
            break; 
        default:
            break;
    }
 
}
#else 
static void on_button(void* pvParameters, gui_menu_t * menu)
{
    kb_evt_t * kb = (kb_evt_t*)pvParameters;
    
    switch( kb->type ) 
    {
        case KB_EVT_CLICK:
        if( p_this_parent != NULL )
        {
            gui_view_create_return( p_this_parent );
            p_this_parent = NULL;
        }
        else 
        {
            gui_view_create_return( &viewAppsList );
        }
            break; 
        default:
            break;
    }
 
}
#endif 

static void on_event_update(void * pvParameters, gui_menu_t * menu)
{
    // nothings to do 
}

static void local_view_event_handler(uint32_t tag )
{
    switch( tag ) 
    {
        case tagTimerStart:
        
        //更新日期
        if(pdate_st->cb)
        {
            pdate_st->cb(year_selected_index, month_selected_index+1,day_selected_index+1);
            pdate_st->cb = NULL;
        }
        
        //获得年
        if(pdate_st->pyear)
        {
            *pdate_st->pyear = year_selected_index;
            pdate_st->pyear = NULL;
        }
        
        //获得月
        if(pdate_st->pmonth)
        {
            *pdate_st->pmonth = month_selected_index+1;
            pdate_st->pmonth = NULL;
        }

        //获得日
        if(pdate_st->pday)
        {
            *pdate_st->pday = day_selected_index+1;
            pdate_st->pday = NULL;
        }
        
		//接着往下执行,不break;
		
        //case tagTimerCancel:
        // 创建界面
        if( p_this_parent != NULL )
        {
            gui_view_create_return( p_this_parent );
            p_this_parent = NULL;
        }
        else 
        {
            gui_view_create_return( views_load_current_watchface() );
        }
        gui_fling_set_disable( m_year_fling );
        break;

        case tagTimerYearSelected:
        // hold active on HOUR        
        m_timer_fling_flags = FLING_YEAR_ENABLED;
        gui_fling_on_touch_press( m_year_fling ); 
        VTLOG0("select year");
        break;

        case tagTimerMonthSelected:
        // hold active on MINUTE
        m_timer_fling_flags = FLING_MONTH_ENABLED;
        gui_fling_on_touch_press( m_month_fling );
        VTLOG0("select month");
        break;        

        case tagTimerDaySelected:
        // hold active on MINUTE
        m_timer_fling_flags = FLING_DAY_ENABLED;
        gui_fling_on_touch_press( m_day_fling );
        VTLOG0("select day");
        break;   
                
        case tagTimerYearClickSelected:
        m_timer_fling_flags = FLING_YEAR_ENABLED;
        VTLOG0("select year by click");
        break;
        
        case tagTimerMonthClickSelected:
        m_timer_fling_flags = FLING_MONTH_ENABLED;
        VTLOG0("select month by click");
        break;
        
        case tagTimerDayClickSelected:
        m_timer_fling_flags = FLING_DAY_ENABLED;
        VTLOG0("select day by click");
        break;
    }
}

